package com.forpastime.forutils.utils;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Result {
    private Integer code;
    private String msg="";
    private Object data;

    public static Result success(){
        Result result = new Result();
        result.setCode(Constants.CODE_SUCCESS);
        return result;
    }

    public static Result success(Object data){
        Result result = new Result();
        result.setCode(Constants.CODE_SUCCESS);
        result.setData(data);
        return result;
    }

    public static Result error(){

        Result result = new Result();
        result.setCode(Constants.CODE_ERROR);
        return result;
    }
    public static Result error(Integer code){

        Result result = new Result();
        result.setCode(code);
        return result;
    }
    public static Result error(String msg){

        Result result = new Result();
        result.setCode(Constants.CODE_ERROR);
        result.setMsg(msg);
        return result;
    }

    public static Result error(String msg, Object data){

        Result result = new Result();
        result.setCode(Constants.CODE_ERROR);
        result.setMsg(msg);
        result.setData(data);
        return result;
    }

    public static Result error(Integer code, String msg){

        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }
    public static Result error(Integer code, Object data){

        Result result = new Result();
        result.setCode(code);
        result.setData(data);
        return result;
    }
}

